Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for create_chart requests without folder_id paramter defined #64

Merged
merged 2 commits into from
Jun 24, 2021

Conversation

elanals
Copy link
Contributor

@elanals elanals commented Jun 23, 2021

Description

This is a proposed fix for issue #61.

Context
Recently there were changes made to the Datawrapper API, whereby POST /charts requests (to create a new chart) now return a 403 if the folder sent in the payload is invalid. i.e if it either:

  • doesn't exist
  • the requesting user doesn't have access to it
  • it conflicts with the organizationId (i.e corresponds to a folder that isn't in that team/organization)

The current implementation in this library is such that if the user doesn't specify a folder_id it gets sent along with the create request as an empty string, which is invalid, so Datawrapper returns a 403 and the chart doesn't get created.

Changes

  • Only pass folderId along with the POST /charts request if the user specified it in their call of create_chart.
  • Extend print output when 403 is returned and a folder_id was defined, that suggests that the folder_id may be the issue

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Checklist

  • I've read the CODE_OF_CONDUCT.md document.
  • I've read the CONTRIBUTING.md guide.
  • I've updated the code style using make codestyle.
    -I've written tests for all new methods and classes that I created.
    - I've written the docstring in Google format for all the methods and classes that I used.

I had to commit with --no-verify because of a failing commit hook, that I unfortunately couldn't figure out how to solve (pretty new to Python, sorry 🙈)

An unexpected error has occurred: CalledProcessError: command: ('/Users/elana/Library/Caches/pypoetry/virtualenvs/datawrapper-rDpTQou8-py3.9/bin/python', '-mvirtualenv', '/Users/elana/.cache/pre-commit/repo4o2s4ioq/py_env-python3.7', '-p', 'python3.7')
return code: 1
expected return code: 0
stdout:
    RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.7'

@chekos
Copy link
Owner

chekos commented Jun 23, 2021

no worries about the failing commit hook! I myself am new to poetry and it's confusing sometimes!!

This PR looks great, thank you so much for doing this @elanals !!

I'll look into the failing commit hook and once that's solved I'll merge and publish a new version of Datawrapper!! Thank you so much for contributing!!!!

@elanals
Copy link
Contributor Author

elanals commented Jun 23, 2021

Thanks a lot for that @chekos! and happy to help :)

@chekos
Copy link
Owner

chekos commented Jun 24, 2021

I'm merging the PR even though the checks are failing because it seems it is pip itself that's causing the security checks to fail but that's been solved on the main branch.

@chekos chekos merged commit 6181069 into chekos:master Jun 24, 2021
@elanals
Copy link
Contributor Author

elanals commented Jul 6, 2021

Didn't see this earlier, but great that the PR is merged and that it wasn't just me who struggled with the checks! Thanks :)

@elanals elanals deleted the fix/folder_id-bug branch July 6, 2021 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants